package com.concurrency.example.visitor;

import java.util.ArrayList;

public class VisitorTest {
    public static void main(String[] args) {
        ConcreteVisitor concreteVisitor = new ConcreteVisitor();

        StringElement abc = new StringElement("abc");
        //通过访问者访问自己的
        abc.accept(concreteVisitor);

        FloatElement floatElement = new FloatElement(new Float(1.5));
        abc.accept(concreteVisitor);

        System.out.println("================");
        ArrayList<Object> result = new ArrayList<>();
        result.add(new StringElement("abc"));
        result.add(new StringElement("abc"));
        result.add(new StringElement("abc"));
        result.add(new StringElement("abc"));
        result.add(new FloatElement(new Float(1.5)));
        result.add(new FloatElement(new Float(1.5)));
        result.add(new FloatElement(new Float(1.5)));
        result.add(new FloatElement(new Float(1.5)));

        concreteVisitor.visitCollection(result);
    }
}
